package com.csun.cmny.provider.controller.admin;

import com.csun.cmny.core.support.BaseController;
import com.csun.cmny.provider.model.dto.patrol.PatrolRecordQueryDto;
import com.csun.cmny.provider.model.vo.patrol.PatrolRecordVo;
import com.csun.cmny.provider.resolver.CmnyMessageSource;
import com.csun.cmny.provider.service.DmcPatrolRecordService;
import com.csun.cmny.util.wrapper.WrapMapper;
import com.csun.cmny.util.wrapper.Wrapper;
import com.github.pagehelper.PageInfo;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2021/7/23 17:24
 * @Description: 巡更棒记录拦截器
 */
@RestController
@RequestMapping(value = "/patrolRecord", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class DmcPatrolRecordController extends BaseController {

    @Resource
    private CmnyMessageSource cmnyMessageSource;
    @Resource
    private DmcPatrolRecordService dmcPatrolRecordService;

    /**
     * 查询列表 - 分页
     *
     * @param patrolRecordQueryDto
     *
     * @return
     */
    @RequestMapping(value = "/queryListWithPage", method = RequestMethod.POST)
    public Wrapper queryListWithPage(@RequestBody PatrolRecordQueryDto patrolRecordQueryDto) {

        patrolRecordQueryDto.setGroupId(getLoginAuthDto().getGroupId());
        List<PatrolRecordVo> patrolRecordVoList = dmcPatrolRecordService.queryListWithPage(patrolRecordQueryDto);

        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,
                cmnyMessageSource.getMessage("operation.success", null),
                new PageInfo<>(patrolRecordVoList));
    }

}
